<template>
  <div>
    <ReLine>系统访问数据</ReLine>
    <br />
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card>
          <div class="card-wrap">
            <div class="header-title">
              华润雪花工程项目管理平台2022年1月17日上线至今，平台新增项目情况如下：
            </div>
            <div>
              <ul class="title-card-projectNum">
                <li v-for="(item, index) in projectNumList" :key="index">
                  <div class="item">
                    <div class="item-bottom">{{ item.key }}:</div>
                    <div class="item-top">{{ item.value }}</div>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="12">
        <el-card>
          <ReBar>验收单据业务数据</ReBar>
        </el-card>
      </el-col>
    </el-row>
    <br />

    <el-row :gutter="20">
      <el-col :span="12">
        <el-card>
          <ReBarDevelop>各项目业务数据</ReBarDevelop>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card>
          <RePie>各模块业务数据</RePie>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import {
  RePie,
  ReLine,
  ReBar,
  ReBarDevelop
} from "/@/components/ReCharts/index";
import { postProjectNum } from "/@/api/analysis";

let projectNumList = ref([
  { key: "一级项目数", value: 0 },
  { key: "所有层级项目数", value: 0 }
]);

const initProjectNum = async () => {
  try {
    const { code, data } = await postProjectNum({});
    if (code === 200) {
      // console.log(data);
      projectNumList.value[0].value = data.topProjects;
      projectNumList.value[1].value = data.allProjects;
    }
  } catch (err) {
    console.log(err);
  }
};

initProjectNum();
</script>

<style lang="scss" scoped>
.top-title {
  font-size: 16px;
  font-weight: bold;
}
.card-wrap {
  min-height: 300px;
  padding: 20px;
  .header-title {
    margin-bottom: 20px;
    margin-top: 20px;
    @extend .top-title;
  }
}
.title-card-projectNum {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 1;
  gap: 10px;
  width: 100%;
  height: 80px;
  // margin-top: 30px;
  li {
    .item {
      margin-top: 10px;
      width: 100%;
      height: 100%;
      min-height: 80px;
      border-radius: 8px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      color: #0c045d;
      .item-top {
        margin-top: 30px;
        text-align: center;
        font-size: 50px;
      }
      .item-bottom {
        text-align: center;
        font-size: 24px;
        margin-right: 20px;
        // margin-bottom: 20px;
      }
    }
  }
}
</style>
